import Vue from "vue";
import Router from "vue-router";
import Hall from "./Hall.vue";
import Login from "./Login.vue";
import Machine from "./Machine.vue";
import Chart from "./Chart.vue";

Vue.use(Router);

const router = new Router({
  mode: "history",
  routes: [
    {
      path: "/",
      name: "Hall",
      meta: {
        title: "首页",
        topnav: true,
        backgroundColor: "#fff"
      },
      component: Hall
    },
    {
      path: "/Login",
      name: "Login",
      meta: {
        title: "登录",
        topnav: true,
        backgroundColor: "#fff"
      },
      component: Login
    },
    {
      path: "/Machine/:machineid",
      name: "Machine",
      meta: {
        title: "机器详情",
        topnav: true,
        backgroundColor: "#fff"
      },
      component: Machine
    },
    {
      path: "/Chart/:machineid",
      name: "Chart",
      meta: {
        title: "销售详情",
        topnav: true,
        backgroundColor: "#fff"
      },
      component: Chart
    }              
  ],
  scrollBehavior(to, from) {
    from.meta.scrollTop = window.scrollY;
    return { x: 0, y: to.meta.scrollTop || 0 };
  }
});

export default router;